<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //第一种获取成功与失败
        let p = new Promise((resolve, reject) => {
            resolve('成功')
            // reject('失败')
        })
        console.log(p) //Promise {<fulfilled>: '成功'} 或者 Promise {<rejected>: '失败'}
        p.then(res => {
            console.log(res)//成功
        }).catch(err => {
            //失败
            console.log(err)//成功
        })

        //第二种获取成功与失败
        p.then(res => {
            console.log(res)
        }, (err) => {
            console.log(err)
        })

    </script>

</body>

</html>